package com.easybuilder.core.function.controller;

import com.easybuilder.common.base.controller.BaseController;
import com.easybuilder.core.function.entity.SysFunction;
import com.easybuilder.core.function.service.SysFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/sys/function")
public class SysFunctionController extends BaseController {

    @Autowired
    private SysFunctionService functionService;

    @PostMapping("/save")
    public Result<Object> save(@RequestBody SysFunction sysFunction, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            String message = bindingResult.getFieldError().getDefaultMessage();
            return Error(HttpStatus.BAD_REQUEST, message);
        }
        boolean save = functionService.save(sysFunction);
        return null;
    }
}
